class Template < ActiveRecord::Base
  file_column :filename #, :fix_file_extensions => false
  file_column :preview , :magick => {:versions => {'thumb' => '100x100>'}}
  has_and_belongs_to_many :images

  acts_as_taggable

  validates_uniqueness_of :title
  #validates_presence_of :title, :filename, :preview

  def related_templates
    Template.find_related_tagged(self)
  end

  # active_scaffold callbacks: authorized_for_crud
  def authorized_for_create?
    true
  end

  def authorized_for_read?
    true
  end

  def authorized_for_update?
    true
  end

  def authorized_for_destroy?
    true
  end

  # human names
  ModelName = "PPT模版"
  ColumnNames ={
    :title => "名称",
    :filename => "文件",
    :preview => "预览",
    :images => "用到的图片",
    :tag_list => "标签",
    :related_templates => "相关模板"
  }
end
